package com.hailong.zyt.config;

import com.hailong.zyt.intercepter.AdminIdentityInterceptor;
import com.hailong.zyt.intercepter.LoginInterceptor;
import com.hailong.zyt.intercepter.StudentIdentityInterceptor;
import com.hailong.zyt.intercepter.TeacherIdentityInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyConfig implements WebMvcConfigurer {

    /**
    * 配置拦截器
    * */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/", "/index/**", "/css/**", "/fonts/**", "/images/**", "/js/**", "/index.html", "/favicon.ico", "/error");

        registry.addInterceptor(new StudentIdentityInterceptor())
                .addPathPatterns("/student/**");

        registry.addInterceptor(new TeacherIdentityInterceptor())
                .addPathPatterns("/teacher/**");

        registry.addInterceptor(new AdminIdentityInterceptor())
                .addPathPatterns("/admin/**");
    }
}
